<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改信息')" />

</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">

        <form class="form-horizontal m"  id="form-data"   >

            <div class="form-group">
                <label  class="col-sm-3 control-label">上级目录：</label>
                <div class="col-sm-8">
                    <input type="hidden" id="areaId" name="areaId"  th:value="${area.areaId}">
                    <input type="hidden" id="parentId" name="parentId"  th:value="${area.parentId}">
                    <input type="hidden" id="level" name="level" th:value="${area.level}">
                    <b th:text="${parentName}"></b>
                </div>
            </div>

            <div class="form-group">
                <label  class="col-sm-3 control-label is-required" >名称</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="areaName" th:value="${area.areaName}" required>
                </div>
            </div>

        </form>


    </div>


</body>

<th:block th:include="include :: footer" />

<script type="text/javascript">
    /**
     * 点击了模态框的提交按钮以后触发的事件（名称必须叫 submitHandler）
     */
    function submitHandler() {
        if ($.validate.form()) {
            edit();
        }
    }



    /**
     * 向后台java发送ajax提交请求
     */
    function edit(){
        //手工收集
        // var formData={};
        // formData.name=$("#form-add input[name='name']").val();
        // formData.status=$("#form-add select[name='status']").val();

        //另一种写法，jquery帮你封装表单序列化方法 (全自动收集)  $.serialize("#form-add")
        var formDataString= $("#form-data").serialize();

        $.ajax({
            type:"post",
            url:ctx+"admin/area/edit",
            data: formDataString,
            dataType:"json",
            //同步
            async: false,
            success:function(resp){
                //调用别人帮你封装好的方法
                $.operate.successCallback(resp);
            },error:function(e){
                console.log(e);
                $.modal.alertError("系统错误");
            }
        });

    }



</script>

</html>